package com.kelvem.saas.workbanch.core.exception;

import java.util.Collection;

public class SaasAssert {

     private SaasAssert() {
         // do nothing
     }
    
    public static void notNull(Object obj) {
        notNull(obj, ErrorCodeEnum.COMMON_PARAM_NULL);
    }
    
    public static void notNull(Object obj, ErrorCodeEnum errorCode) {
        if (obj == null || "".equals(obj)) {
            throw new SaasException(errorCode);
        }
    }

    // todo not null  vs  not empty
    public static void notNull(Object obj, String message) {
        if (obj == null || "".equals(obj)) {
            throw new SaasException(message);
        }
    }

    // todo Collection需要合并到object中
    public static void notEmpty(Collection<?> collection) {
        if (collection == null || collection.size() <= 0) {
            throw new SaasException(ErrorCodeEnum.COMMON_PARAM_EMPTY);
        }
    }

    public static void notEmpty(Collection<?> collection, ErrorCodeEnum errorCode) {
        if (collection == null || collection.size() <= 0) {
            throw new SaasException(errorCode);
        }
    }
    
    public static void notEmpty(Collection collection, String message) {
        if (collection == null || collection.size() <= 0) {
            throw new SaasException(message);
        }
    }
}
